package com.rise.servermap;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;

import com.rise.externalservice.IServerMap;

public class Activator implements BundleActivator {

	private static BundleContext context;

	private String bundleName;

	static BundleContext getContext() {
		return context;
	}

	public void start(BundleContext bundleContext) throws Exception {
		this.bundleName = (String) bundleContext.getBundle().getHeaders()
				.get(Constants.BUNDLE_NAME);

		System.out.println("Bundle inicializado: " + this.bundleName);

		ServerMap service = new ServerMap();
		bundleContext.registerService(IServerMap.class.getName(), service, null);

		System.out.println(service.getMap(null).toString());
	}

	public void stop(BundleContext bundleContext) throws Exception {
		System.out.println("Bundle finalizado: " + this.bundleName);
	}

}
